package com.fzz.dao;

import com.fzz.domain.User;
import com.fzz.domain.View;
import org.apache.ibatis.annotations.*;
import org.springframework.data.relational.core.sql.In;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Mapper
public interface ViewMapping {


    //添加视频
    @Insert("insert into tb_view(viewUrl,imgUrl,viewName) values(#{viewUrl},#{imgUrl},#{viewName})")
    public void addView(View view);

    //导入视频
    @Select("select * from tb_view")
    public List<View> loadView();

    //分页查询视频
    @Select("<script> " +
            "select * from tb_view where 1=1 " +
            "<if test='id!=null'>and id=#{id}</if>" +
            "<if test='viewName!=null'> and viewName like concat('%',#{viewName},'%')</if>" +
            "</script>")
    public List<View> selectViewWithPage(@Param("id") Integer id, @Param("viewName") String viewName);

    //修改视频信息
    @Update("update tb_view set viewName=#{viewName},viewUrl=#{viewUrl},imgUrl=#{imgUrl} where id=#{id}")
    public Integer updateViewInfoById(View view);

    //根据id删除视频
    @Delete("delete from tb_view where id=#{id}")
    public Integer deleteViewById(@Param("id") Integer id);

    @Select("select * from tb_view")
    public List<View> selectViewWithPageShow();
}





